package com.qiujianwei.study.authcenter.entity;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Set;

@Data
@NoArgsConstructor
public class LoginUser implements UserDetails, Serializable {

    /**
     * 用户的基本信息
     */
    private SystemUserEntity systemUserEntity;

    /**
     * 用户所拥有的的权限Id列表
     */
    private List<String> powers;

    public LoginUser(SystemUserEntity systemUserEntity) {
        this.systemUserEntity = systemUserEntity;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return systemUserEntity.getPassword();
    }

    @Override
    public String getUsername() {
        return systemUserEntity.getUserName();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
